package com.kantboot.tool.edu.web.controller;

import com.kantboot.global.rest.result.CommonSuccessStateCodeAndMsg;
import com.kantboot.tool.edu.service.IToolEduMajorService;
import com.kantboot.util.common.result.RestResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 专业
 * 用于管理专业的查询
 */
@RestController
@RequestMapping("/tool-edu/major")
public class ToolEduMajorController {

    @Resource
    private IToolEduMajorService toolEduMajorService;

    @RequestMapping("/getByCode")
    public RestResult<Object> getByCode(@RequestParam("code") String code) {
        return RestResult.success(toolEduMajorService.getByCode(code), CommonSuccessStateCodeAndMsg.GET_SUCCESS);
    }

    @RequestMapping("/getByCodeHasChildren")
    public RestResult<Object> getByCodeHasChildren(@RequestParam("code") String code) {
        return RestResult.success(toolEduMajorService.getByCodeHasChildren(code), CommonSuccessStateCodeAndMsg.GET_SUCCESS);
    }

    @RequestMapping("/getAll")
    public RestResult<Object> getAll() {
        return RestResult.success(toolEduMajorService.getAll(), CommonSuccessStateCodeAndMsg.GET_SUCCESS);
    }

    @RequestMapping("/getAllHasChildren")
    public RestResult<Object> getAllHasChildren() {
        return RestResult.success(toolEduMajorService.getAllHasChildren(), CommonSuccessStateCodeAndMsg.GET_SUCCESS);
    }

}
